package com.itheima.Thraed.ThreadPrinciple;

public class demo9 {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("系茶壶");
                try {
                    Thread.sleep(1000);
                    System.out.println("洗茶杯");
                    Thread.sleep(5000);
                    System.out.println("等水烧开");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        Thread t2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("洗水壶");
                try {
                    Thread.sleep(1000);
                    System.out.println("拿茶叶");
                    t1.join();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        t1.start();
        t2.start();
    }
}
